package com.example.shop.common.api;

/**
 * 常用API响应码
 */
public enum ServiceStateCode implements StateCode{
//==========================|| 服务器响应码 ||===================================
    DISABLE_MALICIOUS_REQUEST(100,"禁止恶意请求"),
    SUCCESS(200,"业务正确执行"),
    PARAMETER_NONSTANDARD(405,"参数不规范"),
    IRREGULAR_ACCESS(406,"访问不规范"),
    FAILURE(500,"服务器出错了"),
//============================|| Dao响应码 ||====================================
    NO_SUCH_RECORD(550,"不存在该记录"),
//============================|| 其他响应码 ||====================================
    LOGIN_AFTER_OPERATION(600,"登录后才可以操作"),
    AUTH_CODE_TIMEOUT(601,"授权码过时"),
    AUTH_CODE_NOT_CORRECT(602,"授权码不正确"),
    EMAIL_HAS_BEEN_SENT(603,"邮件已经发送过了"),
    SMS_HAS_BEEN_SENT(604,"短信已经发送过了"),
    SEND_FAILURE(605,"发送失败"),
    MORE_THAN_RATED_VALUE(606,"超过规定值"),
    ALREADY_ENABLE(607,"已经开启该功能了"),
    ALREADY_DISABLE(608,"已经禁用该功能了"),
//=============================|| 人脸识别响应码 ||=========================
    UNABLE_RECOGNITION(0,"无法识别出用户"),
    FACE_PICTURE_IS_NOT_PERSONAL(1,"图片不是个人照"),
    IMAGE_ERROR_UNSUPPORTED_FORMAT(2,"不支持该图片格式"),
    FACE_ALREADY_BOUND(3,"该人脸已经被绑定过"),
//=============================|| 登录响应码 ||=============================
    NO_EXIST_USER(50,"不存在该用户"),
    NO_EXIST_MERCHANT(51,"不存在该商家"),
    ACCOUNT_PASSWORD_NO_MATCH(52,"用户名和密码不匹配"),
//=============================|| 注册注销绑定更改用户信息响应码 ||=============================
    ACCOUNT_HAS_BEEN_REGISTER(100,"该账户已经被注册"),
    USER_EMAIL_ALREADY_BOUND(101,"用户邮箱已经被绑定了"),
    PHONE_ALREADY_BOUND(102,"该手机号已经被绑定了"),
    ACCOUNT_CANNOT_BE_EMPTY(103,"账户为空"),
    PERSON_HAS_ALREADY_REGISTER(104,"该人已经注册过用户"),
    OLD_PASSWORD_NOT_INCORRECT(105,"旧密码不正确"),
    USER_NOT_BIND_PHONE(106,"该用户没有绑定手机号"),
    USER_NOT_BIND_EMAIL(107,"该用户没有绑定邮箱"),
//============================|| 评价、评论、回复评论响应码 ||======================================
    NO_SUCH_EVALUATION(650,"不存在该评价"),
    IN_EVALUATION_NO_SUCH_REPLY_USER(651,"在该评价里不存在该回复用户"),
//============================|| 订单响应码 ||======================================
    NOT_EXIST_ORDER(700,"订单不存在"),
//============================|| 商品响应码 ||======================================
    STYLE_ALREADY_EXIST(750,"该商品的款式已经存在"),
    NOT_EXIST_GOODS(751,"该商品不存在"),
    NOT_EXIST_GOODS_CLASS(752,"不存在该款式"),
    INSUFFICIENT_INVENTORY(753,"该款式的库存不足"),
    CANT_WITHOUT_GOODS_CLASS(754,"商品不能没有款式"),
//=============================|| 定位服务响应码 || ==================================
    DIFFICULT_LOCATE(800,"定位精度过小,精度最小应该在乡镇级别"),
    CANT_UNDERSTAND_LOCATE(801,"无法理解信息，进行定位到指定位置"),
//=============================|| 联系人地址簿 ||===========================================
    NOT_EXIST_LINKMAN(850,"不存在该联系人"),

//==============================|| websocket响应码 ||===================================
    No_PERMISSION_TO_SEND(900,"没有权限作为该用户发送")
    ;
    private long code;
    private String message;

    private ServiceStateCode(long code, String message) {
        this.code = code;
        this.message = message;
    }

    public long getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * 如果业务正常执行，则会返回SUCCESS
     * 所以correctExecBusiness是判断是否返回SUCCESS
     * 如果是，则返回true，否则返回false
     * @return
     */
    public boolean correctExecBusiness(){
        if(ServiceStateCode.SUCCESS.equals(this)){
            return true;
        }
        return false;
    }
}
